const ExtractTextPlugin = require('extract-text-webpack-plugin')

module.exports = {
  /*
   ** Headers of the page
   */
  head: {
    title: 'ssr',
    htmlAttrs:"xxxxxx",
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: 'Nuxt.js project' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ]
  },
  /*
   ** Customize the progress-bar color
   */
  loading: { color: '#3B8070' },
  /*
   ** Build configuration
   */
  build: {
    /*
     ** Run ESLINT on save
     */
    // extend (config, ctx) {
    //   if (ctx.dev && ctx.isClient) {
    //     config.module.rules.push({
    //       enforce: 'pre',
    //       test: /\.(js|vue)$/,
    //       loader: 'eslint-loader',
    //       exclude: /(node_modules)/
    //     })
    //   }
    // }

    // extend (config, { isClient }) {
    //
    //   config.module.rules.push({
    //     test: /\.vue$/,
    //     loader: 'vue-loader',
    //     options: {
    //       // enable CSS extraction
    //       extractCSS: true
    //     }
    //   })
    //
    //   config.plugins.push(new ExtractTextPlugin({ filename: 'common.[chunkhash].css' }))
    // }

    // or
    extend (config, { isClient }) {
      // 为 客户端打包 进行扩展配置
      if (isClient) {
        config.devtool = 'eval-source-map'
      }
    },
    loaders: [
      {
        test: /\.(png|jpe?g|gif|svg)$/,
        loader: 'url-loader',
        query: {
          limit: 1000000000, // 10KO
          name: 'img/[name].[hash].[ext]'
        }
      }
    ],
    vendor: ['axios', 'lodash', 'echarts'],
    analyze: {
      analyzerMode: 'static'
    }
  }
}
